﻿using NUnit.Framework;
using Dsl.Ped.Common.Converters;

namespace DSLPedCommonTest.Converters
{
    [TestFixture, RequiresSTA]
    public class ObjectToTypeCheckConverterTest
    {
        private interface TheInterface
        {
            
        }

        private interface TheInterface2
        {
            
        }

        private class TheClass : TheInterface
        {
            
        }
        
        private ObjectToTypeCheckConverter converter;

        [SetUp]
        public void SetUpForEachTest()
        {
            converter = new ObjectToTypeCheckConverter();          
        }

        [Test]
        public void ObjectToTypeCheckConverterTest1()
        {                                     
            var obj = converter.Convert(null, typeof(bool), null, null);
            Assert.AreEqual(false, obj);
        }

        [Test]
        public void ObjectToTypeCheckConverterTest2()
        {
            var obj = converter.Convert("hello", typeof(bool), null, null);
            Assert.AreEqual(false, obj);
        }

        [Test]
        public void ObjectToTypeCheckConverterTest3()
        {
            var obj = converter.Convert(new TheClass(), typeof(bool), new TheClass(), null);
            Assert.AreEqual(false, obj);
        }

        [Test]
        public void ObjectToTypeCheckConverterTest4()
        {
            var obj = converter.Convert(new TheClass(), typeof(bool), typeof(TheInterface2), null);
            Assert.AreEqual(false, obj);
        }

        [Test]
        public void ObjectToTypeCheckConverterTest5()
        {
            var obj = converter.Convert(new TheClass(), typeof(bool), typeof(TheInterface), null);
            Assert.AreEqual(true, obj);
        }
    }
}
